// 方式一
// 嵌套循环
// 时间：超时
function maxArea(height) {
  const len = height.length;
  let ret = 0;
  for (let n = 0; n < len; n++) {
    for (let k = n + 1; k < len; k++) {
      const diff = k - n;
      const h = Math.min(height[n], height[k]);
      console.log(diff, h);
      ret = Math.max(h * diff, ret);
    }
  }
  return ret;
}

console.log(maxArea([1, 2, 3, 4, 5]));
